

#ifndef _K_MEMORY_MANAGER_DEFINE_H_
#define _K_MEMORY_MANAGER_DEFINE_H_


#include "MyTypes.h"
#include "Functions.h"


// dll specific macro
#ifndef K_DLL_API
	#ifdef	SHARE_STATIC
		#define K_DLL_API
	#else
		#define	K_DLL_API	__declspec(dllexport)
	#endif //SHARE_STATIC
#endif //K_DLL_API


// some flags
#define MEMFLAG_PROTECT		(1<<0)		// protectable
#define MEMFLAG_REPORT		(1<<1)		// repotable
#define MEMFLAG_FREEONEXIT	(1<<2)		// auto dealloc on exit
#define MEMFLAG_NOCHECK		(1<<3)		// do not check
#define MEMFLAG_REPORTING	(1<<4)		// must report
#define MEMFLAG_DESTROYED	(1<<5)		// this item is deleted

// some structure
typedef struct 
{
	uint32	alloccount;				// count of memory allocated
	uint32	curralloccount;			// count of current allocated memory
	uint32	maxalloccount;			// count of maximum allocated memory
	uint32	totalallocated;			// amount of total allocated memory
	uint32	maxallocated;			// amount of maximum allocated memory
	uint32	currallocated;			// amount of current allocated memory
	int		averagesize;			// average size of memory allocated
} MEMSTATS;


// Memory specific API
#ifdef _DEBUG
void	K_DLL_API MemCheckHeap();
void	K_DLL_API *MemAlloc( size_t len, CSTR varname, CSTR filename, int32 linenumber);
void	K_DLL_API *MemReAlloc(void *ptr, size_t len, CSTR varname, CSTR filename, int32 linenumber);
void	K_DLL_API *MemAllocZero( size_t len, CSTR varname, CSTR filename, int32 linenumber);
void	K_DLL_API MemDumpAllocations();
#endif // _DEBUG

void	K_DLL_API *MemAlloc( size_t len );
void	K_DLL_API *MemReAlloc( void *ptr, size_t len );
void	K_DLL_API *MemAllocZero( size_t len );
void	K_DLL_API MemFree( void * mem );

MEMSTATS	K_DLL_API	*GetMemStat();


#endif